package controller

import (
	"github.com/gin-gonic/gin"
	"gormstu/model"
	"net/http"
)

type MultiController struct {
}

// MultiTableSearch 获取文章对应的分类 ==> 多表查询
func (mc MultiController) MultiTableSearch(ctx *gin.Context) {

	var article []model.Article
	model.DB.Preload("ArticleCate").Find(&article)

	ctx.JSON(http.StatusOK, gin.H{
		"article": article,
	})

}

func (mc MultiController) OneToMulti(ctx *gin.Context) {
	var articleCate []model.ArticleCate
	model.DB.Preload("Article").Find(&articleCate)
	ctx.JSON(http.StatusOK, gin.H{
		"article_cate": articleCate,
	})
}
